// function UseEffectCom(){
//     return(
//         <div></div>
//     )
// }
// export default UseEffectCom;

import { useEffect, useState } from "react"
export default () => {

    const [count, setCount] = useState(0);
    const [user, setUser] = useState({ name: "张三" });

    useEffect(() => {
        console.log("挂载完成");

        return () => {
            console.log("销毁");
        }


    }, [])

    useEffect(() => {
        console.log("更新");
    }, [count])


    const update = () => {

        setUser({ ...user, name: "李四" })
    }


    return (
        <div>useEffect
            <div>{user.name}</div>

            <div>{count}</div>

            <button onClick={() => setCount(100)}>修改</button>
            <button onClick={update}>修改</button>

        </div>
    )
}
